# class Employee:
#     def __init__(self, employee_id, name, position):
#         self.employee_id = employee_id  # 员工ID
#         self.name = name  # 员工姓名
#         self.position = position  # 员工职位
#
#     def __repr__(self):
#         return f"Employee(ID={self.employee_id}, Name={self.name}, Position={self.position})"
#
# class Company:
#     def __init__(self, company_name, employees=None):
#         self.company_name = company_name  # 公司名称
#         self.employees = employees if employees is not None else []  # 存储员工列表，默认为空列表
#
#     def __repr__(self):
#         # 展示公司及其员工信息
#         employees_repr = "\n".join(f"  {repr(emp)}" for emp in self.employees)
#         return f"Company(CompanyName = {self.company_name})\n{employees_repr}"
#
# if __name__ == "__main__":
#     # 创建员工实例
#     employees = [
#         Employee(2024001, "ZhangSan", "Engineer"),
#         Employee(2024002, "LiSi", "Manager"),
#         Employee(2024003, "WangWu", "Designer")
#     ]
#
#     # 创建公司实例并设置员工列表
#     company = Company("Tencent", employees)
#
#     # 打印公司信息及员工列表
#     print(company)

# # 定义家庭成员类
# class FamilyMember:
#     def __init__(self, name, age):
#         self.name = name
#         self.age = age
#
#     def __str__(self):
#         return f"name={self.name}, age={self.age}"
#
#     # 定义家庭类
# class Family:
#     def __init__(self):
#         self.members = []
#
#     def add_member(self, member):
#         self.members.append(member)
#
#     def __str__(self):
#         member_strings = [f"  {str(member)}\n" for member in self.members]  # 注意这里的换行符 \n 和缩进
#         return "Family Members:\n" + "".join(member_strings)
#
# def main():
#     # 创建家庭成员对象
#     father = FamilyMember("John", 45)
#     mother = FamilyMember("Jane", 42)
#     child = FamilyMember("Emily", 10)
#
#     # 创建家庭对象
#     my_family = Family()
#
#     # 将家庭成员添加到家庭中
#     my_family.add_member(father)
#     my_family.add_member(mother)
#     my_family.add_member(child)
#
#     # 打印家庭信息
#     print(my_family)
#
# # 调用主函数
# if __name__ == "__main__":
#     main()

# 定义硬件类（B类）
class Hardware:
    def __init__(self, name, description):
        self.name = name
        self.description = description

    def __str__(self):
        return f"{self.name}: {self.description}"

    # 定义计算机系统类（A类）
class ComputerSystem:
    def __init__(self):
        self.hardware_components = []

    def add_hardware(self, hardware):
        self.hardware_components.append(hardware)

    def __str__(self):
        hardware_strings = [f"\t- {str(hw)}\n" for hw in self.hardware_components]
        return "Computer System\n" + "".join(hardware_strings)

def main():
    # 创建硬件对象
    cpu = Hardware("CPU", "Intel Core i7")
    gpu = Hardware("GPU", "NVIDIA GeForce RTX 3080")
    ram = Hardware("RAM", "16GB DDR4")

    # 创建计算机系统对象
    my_computer = ComputerSystem()

    # 将硬件添加到计算机系统中
    my_computer.add_hardware(cpu)
    my_computer.add_hardware(gpu)
    my_computer.add_hardware(ram)

    # 打印计算机系统信息
    print(my_computer)

    # 单独打印硬件对象（展示B类实例可以单独存在）
    print(cpu)
    print(gpu)

# 调用主函数
if __name__ == "__main__":
    main()